using BlogEngine.Core;
using BlogEngine.MongoDbProvider;
using MongoDB.Driver;
using NUnit.Framework;
using Rhino.Mocks;
using SharpTestsEx;

namespace Providers.Specs
{
    [TestFixture]
    public class MongoDB_specifications
    {
        private const string _dbName = "BlogEngineTest";

        [Test]
        public void When_calling_insert_Should_insert_to_a_collection()
        {
            var mongoDb = new MongoDb(_dbName);
            var objectToSave = new Post {Title = "New post"};
            mongoDb.Insert(objectToSave);

            var docId = objectToSave.Id.ToString();
            var savedObject = mongoDb.GetServer().GetCollection<Post>()
                .FindOne(new Post{Id=objectToSave.Id});

            objectToSave.Id.Should().Be.EqualTo(savedObject.Id);
        }
    }
}